{include file="common/top" /}
<style>
html{
	background: #ffffff;
}
</style>
<form class="layui-form " action="" style="    background: #fff;">
    <div class="layui-form-item">
		<label class="layui-form-label">标题：</label>
		<div class="layui-col-xs4">
			<input type="text" name="title" value="{$rs.title}" lay-verify="required" autocomplete="off" placeholder="请输入标题" class="layui-input">
		</div>
        <label class="layui-form-label">作者：</label>
		<div class="layui-col-xs4">
			<select name="author_id" lay-verify="required" lay-search=""  lay-verify="required" autocomplete="off">
				<option value="">直接选择或搜索选择</option>
				{volist name="author" id='zz'}
					<option value="{$zz.id}" {eq name="rs.author_id" value="$zz.id"}selected{/eq}>{$zz.name}</option>
				{/volist}
	        </select>
		</div>
	</div>
    <div class="layui-form-item">
        <label class="layui-form-label">平台：</label>
		<div class="layui-col-xs4">
			<select name="platform" lay-verify="required" lay-search=""  lay-verify="required" autocomplete="off">
				<option value="">直接选择或搜索选择</option>
				<option value="1" {eq name="rs.platform" value="1"}selected{/eq}>快手</option>
                <option value="2" {eq name="rs.platform" value="2"}selected{/eq}>知乎</option>
				<option value="3" {eq name="rs.platform" value="3"}selected{/eq}>抖音</option>
				<option value="4" {eq name="rs.platform" value="4"}selected{/eq}>微信</option>
	        </select>
		</div>
		<label class="layui-form-label">标签：</label>
		<div class="layui-col-xs4">
            <div id="demo2" ></div>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">描述：</label>
		<div class="layui-col-xs9">
			<textarea name="describe" autocomplete="off" placeholder="请输入描述" class="layui-textarea">{$rs.describe}</textarea>
		</div>
	</div>
    <div class="layui-form-item">
		<label class="layui-form-label">内容：</label>
		<div class="layui-col-xs10">
			<textarea id="demo" style="display: none;">{$rs.content}</textarea>
		</div>
	</div>
	
	<hr />
	<div class="layui-form-item">
		<div class="layui-input-block">
            <input type="hidden" name="id" value="{$rs.id}"  >
			<button class="layui-btn"  lay-submit="" lay-filter="demo1">修改</button>
		</div>
	</div>
	
</form>
{include file="common/footer" /}
<script src="__static/js/xm-select.js" charset="utf-8"></script>
<script>
	layui.use(['form', 'layedit', 'laydate'], function(){
		  var form = layui.form ,layer = layui.layer,layedit = layui.layedit;
		  layedit.set({
			uploadImage: {
				url: '{:url("Upload/layui_update")}', //接口url
				type: 'post' //默认post
			}
		});
          var wb1 = layedit.build('demo'); //建立编辑器
		  //监听提交
		  form.on('submit(demo1)', function(data){
            var company_wishes = layedit.getContent(wb1);
			var articleFrom = data.field;
            articleFrom. content = company_wishes;
            delete articleFrom.file;
            // console.log(articleFrom);
			layer.load(1, { shade : [ 0.5, '#676a6c' ] }); 
			$.post("{:url('save_copywriter')}?t=json",articleFrom,function(data){
				layer.closeAll();
				if (data['code'] == 1) { 
					var index1 = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
					parent.layer.close(index1); //再执行关闭 
					//父页面数据 ，重新加载
					parent.get_s(data['msg']);

				} else {
					layer.msg(data['msg'], { icon : 5 });
				}
			});
			
			return false;
		  });
        get_yy()
		var demo3;
		function get_yy(){
			layer.load(1, { shade : [ 0.5, '#676a6c' ] });
			$.post("{:url('get_label')}?t=json",{},function(data){
				layer.closeAll();
				if (data['code'] == 1) {
					demo3 = xmSelect.render({
						el: '#demo2', 
						toolbar: {
							show: true,
							showIcon: false,
						},
						name:'label_id',
						data: data.data
					})
                    get_v();
				} else {
					layer.msg(data['msg'], { icon : 5 });
				}
			});
		}
		// form.on('select(aihao)', function(data){
		// 	demo1.setValue([ data.value ]);
		// }); 
        
        function get_v(){
            demo3.setValue([ {$rs.label_id} ]);
        };
	});
	
</script>
